import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import axios from 'axios'
import { ElMessage } from 'element-plus'

// 配置axios默认URL
axios.defaults.baseURL = 'http://localhost:8080'

const app = createApp(App)

// 全局配置
app.config.globalProperties.$message = ElMessage

app.use(router)
app.use(store)
app.use(ElementPlus)

// 添加请求拦截器
axios.interceptors.request.use(config => {
  console.log('Request:', config)
  return config
}, error => {
  console.error('Request error:', error)
  return Promise.reject(error)
})

// 添加响应拦截器
axios.interceptors.response.use(response => {
  console.log('Response:', response)
  return response
}, error => {
  console.error('Response error:', error)
  return Promise.reject(error)
})

// 初始化store
store.dispatch('initializeStore').then(() => {
  app.mount('#app')
}) 